﻿using System;
namespace Producers.Liiklusregister.Xtee.Riik.Ee.Producer.Liiklusregister {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="juhid3", Namespace="http://producers.liiklusregister.xtee.riik.ee/producer/liiklusregister", Target=typeof(Juhid3))]
    public class Juhid3Serializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IJuhid3 clazz;
        
        public Juhid3Serializer(IJuhid3 clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("eesnimi");
            if (clazz.Eesnimi!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Eesnimi))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Eesnimi");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("perekonnanimi");
            if (clazz.Perekonnanimi!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Perekonnanimi))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Perekonnanimi");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("synniaeg");
            if (clazz.Synniaeg!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Synniaeg))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Synniaeg");
            }
            Writer.WriteEndElement();
            if (clazz.Isikukood!=null) {
                Writer.WriteStartElement("isikukood");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikukood))).ToString());
                Writer.WriteEndElement();
            }
            Writer.WriteStartElement("synnikoha_riik");
            if (clazz.SynnikohaRiik!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.SynnikohaRiik))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : SynnikohaRiik");
            }
            Writer.WriteEndElement();
            if (clazz.Haldusyksus!=null) {
                Writer.WriteStartElement("haldusyksus");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Haldusyksus))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Aadress!=null) {
                Writer.WriteStartElement("aadress");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Aadress))).ToString());
                Writer.WriteEndElement();
            }
            Writer.WriteStartElement("juhiload");
            if (clazz.Juhiload!=null) {
                global::Xtee.Core.SerializationMetadata metaJuhiload = this.GetMetaData(clazz.Juhiload);
                Writer.WriteTypeAttribute(metaJuhiload.TypeQualifiedName.Namespace, metaJuhiload.TypeQualifiedName.Name);
                metaJuhiload.NewSerializer(clazz.Juhiload).WriteXml(Writer);
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Juhiload");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
        START:
            if ((Reader.LocalName == "eesnimi")) {
                goto eesnimi;
            }
            else {
                if ((Reader.LocalName == "perekonnanimi")) {
                    goto perekonnanimi;
                }
                else {
                    if ((Reader.LocalName == "synniaeg")) {
                        goto synniaeg;
                    }
                    else {
                        if ((Reader.LocalName == "isikukood")) {
                            goto isikukood;
                        }
                        else {
                            if ((Reader.LocalName == "synnikoha_riik")) {
                                goto synnikoha_riik;
                            }
                            else {
                                if ((Reader.LocalName == "haldusyksus")) {
                                    goto haldusyksus;
                                }
                                else {
                                    if ((Reader.LocalName == "aadress")) {
                                        goto aadress;
                                    }
                                    else {
                                        if ((Reader.LocalName == "juhiload")) {
                                            goto juhiload;
                                        }
                                        else {
                                            return;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        eesnimi:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>juhid3>eesnimi");
            }
            clazz.Eesnimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("eesnimi")).Value;
            goto START;
        perekonnanimi:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>juhid3>perekonnanimi");
            }
            clazz.Perekonnanimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("perekonnanimi")).Value;
            goto START;
        synniaeg:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>juhid3>synniaeg");
            }
            clazz.Synniaeg = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("synniaeg")).Value;
            goto START;
        isikukood:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>juhid3>isikukood");
            }
            clazz.Isikukood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("isikukood")).Value;
            goto START;
        synnikoha_riik:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>juhid3>synnikoha_riik");
            }
            clazz.SynnikohaRiik = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("synnikoha_riik")).Value;
            goto START;
        haldusyksus:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>juhid3>haldusyksus");
            }
            clazz.Haldusyksus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("haldusyksus")).Value;
            goto START;
        aadress:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>juhid3>aadress");
            }
            clazz.Aadress = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("aadress")).Value;
            goto START;
        juhiload:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>juhid3>juhiload");
            }
            global::Xtee.Core.SerializationMetadata metaJuhiload = this.GetMetaData<Juhid3.IJuhiloadType>(Reader, ">>juhid3>juhiload", "http://producers.liiklusregister.xtee.riik.ee/producer/liiklusregister");
            clazz.Juhiload = metaJuhiload.NewEntity<Juhid3.IJuhiloadType>();
            if ((Reader.IsEmptyElement == false)) {
                Reader.ReadStartElement("juhiload");
                metaJuhiload.NewSerializer(clazz.Juhiload).ReadXml(Reader);
                Reader.ReadEndElement();
            }
            else {
                Reader.Skip();
            }
            goto START;
        }
        
        [global::Xtee.Core.Attributes.XmlTypeAttribute(Name=">>juhid3>juhiload", Namespace="http://producers.liiklusregister.xtee.riik.ee/producer/liiklusregister", Target=typeof(Juhid3.JuhiloadType))]
        public class JuhiloadTypeSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
            
            protected Juhid3.IJuhiloadType clazz;
            
            public JuhiloadTypeSerializer(Juhid3.IJuhiloadType clazz) {
                this.clazz = clazz;
            }
            
            public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
                base.WriteXml(Writer);
                for (int x = 0; ((clazz.Item != null) 
                            && (x < clazz.Item.Count)); x = (x + 1)) {
                    if (clazz.Item[x]!=null) {
                        Writer.WriteStartElement("item");
                        global::Xtee.Core.SerializationMetadata metaItem = this.GetMetaData(clazz.Item[x]);
                        Writer.WriteTypeAttribute(metaItem.TypeQualifiedName.Namespace, metaItem.TypeQualifiedName.Name);
                        metaItem.NewSerializer(clazz.Item[x]).WriteXml(Writer);
                        Writer.WriteEndElement();
                    }
                }
            }
            
            public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
                base.ReadXml(Reader);
                if (Reader.LocalName=="item") {
                    clazz.Item = new System.Collections.Generic.List<global::Producers.Liiklusregister.Xtee.Riik.Ee.Producer.Liiklusregister.IJuhiload3>();
                    for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                                && (Reader.LocalName == "item")); ) {
                        if (Reader.IsElementNil()) {
                            throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>juhid3>juhiload>item");
                        }
                        global::Xtee.Core.SerializationMetadata metaItem = this.GetMetaData<global::Producers.Liiklusregister.Xtee.Riik.Ee.Producer.Liiklusregister.IJuhiload3>(Reader, "juhiload3", "http://producers.liiklusregister.xtee.riik.ee/producer/liiklusregister");
                        global::Producers.Liiklusregister.Xtee.Riik.Ee.Producer.Liiklusregister.IJuhiload3 item = metaItem.NewEntity<global::Producers.Liiklusregister.Xtee.Riik.Ee.Producer.Liiklusregister.IJuhiload3>();
                        clazz.Item.Add(item);
                        if ((Reader.IsEmptyElement == false)) {
                            Reader.ReadStartElement("item");
                            metaItem.NewSerializer(item).ReadXml(Reader);
                            Reader.ReadEndElement();
                        }
                        else {
                            Reader.Skip();
                        }
                    }
                }
            }
        }
    }
}
